//WA
#include"bits/stdc++.h"
using namespace std;
struct exam{
	int chinese,mathematics,english,total_score;
};
int n,ans;
exam student[1000+10];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>student[i].chinese>>student[i].mathematics>>student[i].english;
		student[i].total_score=student[i].chinese+student[i].mathematics+student[i].english;
	}
	for(int j=0;j<=n-1;j++)
	{
		if(abs(student[j].chinese-student[j+1].chinese)<=5&&abs(student[j].mathematics-student[j+1].mathematics)<=5&&abs(student[j].english-student[j+1].english)<=5&&abs(student[j].total_score-student[j+1].total_score)<=10)
		{
			ans+=1;
		}
	}
	cout<<ans;
}
